package educational.cad.model;

/**
 * This class represents some element position at the board in abstract units.
 * 
 * @author Sergey Seroshtan
 * 
 */
public final class Position {

	public Position(int x, int y) {
		if (x < 0) {
			throw new IllegalArgumentException("X-coordinate is negative.");
		}
		if (y < 0) {
			throw new IllegalArgumentException("Y-coordinate is negative.");
		}
		this.x = x;
		this.y = y;
	}

	public int x() {
		return x;
	}

	public int y() {
		return y;
	}

	private final int x;
	private final int y;

	@Override
	public boolean equals(Object another) {
		return this.x == ((Position) another).x && this.y == ((Position) another).y;
	}

	@Override
	public int hashCode() {
		int hash = 17;
		hash = 31 * hash + x;
		hash = 31 * hash + y;
		return hash;
		
	}

}
